--- Makefile.old	2013-02-12 20:16:28.270982024 -0800
+++ Makefile	2013-02-12 20:30:14.685976331 -0800
@@ -6,8 +6,8 @@
 
 CC   = @gcc
 CXX  = @g++
-CFLAGS ?= -O3 -g3
-CXXFLAGS ?= -O3 -g3
+CFLAGS ?= -g3 -O3 -fPIC
+CXXFLAGS ?= -g3 -O3 -fPIC
 CPPFLAGS += -DNST_PRAGMA_ONCE_SUPPORT -D_SZ_ONE_DIRECTORY
 CPPFLAGS += -Isource -Isource/core -Isource/zlib -Isource/core/api -Isource/core/board -Isource/core/input -Isource/unix/unzip
 CPPFLAGS += -Isource/core/vssystem -Isource/unix -Isource/nes_ntsc -I.. -I../nes_ntsc -Isource/unix/7zip
@@ -48,12 +48,12 @@
 CPPFLAGS += -DDATADIR=\"$(DATADIR)\"
 
 # Linux objs
-OBJS = objs/unix/main.o objs/unix/oss.o objs/unix/interface.o objs/unix/settings.o 
+OBJS = objs/unix/main.o objs/unix/oss.o objs/unix/interface.o objs/unix/settings.o
 OBJS += objs/unix/auxio.o objs/unix/input.o objs/unix/kentry.o objs/unix/controlconfig.o objs/unix/cheats.o
 OBJS += objs/unix/seffect.o objs/unix/uihelp.o
 
 # 7-zip decoder (from LZMA SDK 4.58 beta)
-OBJS += objs/unix/7zip/7zAlloc.o objs/unix/7zip/7zBuf.o objs/unix/7zip/7zCrc.o objs/unix/7zip/7zDecode.o objs/unix/7zip/7zExtract.o 
+OBJS += objs/unix/7zip/7zAlloc.o objs/unix/7zip/7zBuf.o objs/unix/7zip/7zCrc.o objs/unix/7zip/7zDecode.o objs/unix/7zip/7zExtract.o
 OBJS += objs/unix/7zip/7zHeader.o objs/unix/7zip/7zIn.o objs/unix/7zip/7zItem.o objs/unix/7zip/LzmaDec.o
 OBJS += objs/unix/7zip/Alloc.o objs/unix/7zip/Bcj2.o objs/unix/7zip/Bra.o objs/unix/7zip/Bra86.o objs/unix/7zip/BraIA64.o
 
@@ -164,7 +164,7 @@
 OBJS += objs/core/vssystem/NstVsRbiBaseball.o  objs/core/vssystem/NstVsSuperXevious.o  objs/core/vssystem/NstVsSystem.o  objs/core/vssystem/NstVsTkoBoxing.o
 
 # object dirs
-OBJDIRS = objs objs/core objs/core/api objs/core/board objs/core/input objs/core/vssystem objs/nes_ntsc 
+OBJDIRS = objs objs/core objs/core/api objs/core/board objs/core/input objs/core/vssystem objs/nes_ntsc
 OBJDIRS += objs/unix objs/unix/7zip objs/unix/unzip
 
 # build rules
@@ -191,14 +191,13 @@
 
 install:
 	mkdir -p $(DATADIR)/icons
-	mkdir -p $(PREFIX)/share/pixmaps
-	install -m 0755 $(BIN) $(BINDIR)
-	install -m 0644 source/unix/icons/nestopia.desktop $(DATADIR)
-	install -m 0644 NstDatabase.xml $(DATADIR)
+	install -Dm 0755 $(BIN) $(BINDIR)/$(BIN)
+	install -Dm 0644 source/unix/icons/nestopia.desktop $(DATADIR)/nestopia.desktop
+	install -Dm 0644 NstDatabase.xml $(DATADIR)/NstDatabase.xml
 	install -m 0644 source/unix/icons/*.png $(DATADIR)/icons
 	install -m 0644 source/unix/icons/*.svg $(DATADIR)/icons
-	install -m 0644 source/unix/icons/nestopia.svg $(PREFIX)/share/pixmaps
-	xdg-desktop-menu install --novendor $(DATADIR)/nestopia.desktop
+	install -Dm 0644 source/unix/icons/nestopia.svg $(PREFIX)/share/pixmaps/nestopia.svg
+	install -Dm 0644 $(DATADIR)/nestopia.desktop $(PREFIX)/share/applications/nestopia.desktop
 
 uninstall:
 	xdg-desktop-menu uninstall $(DATADIR)/nestopia.desktop
